#include <cassert>
#include <boost/algorithm/string.hpp>
#include <map>

#include "../../../XMLTools.h"

#include "Force1DSensor.h"

using namespace MMM;

Force1DSensorPtr Force1DSensor::loadSensorXML(RapidXMLReaderNodePtr node) {
    Force1DSensorPtr sensor(new Force1DSensor());
    sensor->loadSensor(node);
    return sensor;
}

Force1DSensor::Force1DSensor() : AttachedSensor()
{
}

Force1DSensor::Force1DSensor(const std::string &segment, const std::string &offsetUnit, const Eigen::Matrix4f &offset, const std::string &description) :
    AttachedSensor(segment, offsetUnit, offset, description)
{
}

boost::shared_ptr<BasicSensor<Force1DSensorMeasurement> > Force1DSensor::cloneConfiguration() {
    Force1DSensorPtr m(new Force1DSensor(segment, offsetUnit, offset, description));
    return m;
}

void Force1DSensor::loadMeasurementXML(RapidXMLReaderNodePtr node, float timestep, SensorMeasurementType type)
{
    assert(node);
    assert(node->name() == XML::NODE_MEASUREMENT);

    RapidXMLReaderNodePtr forceNode = node->first_node("Force");
    Force1DSensorMeasurementPtr m(new Force1DSensorMeasurement(timestep, XML::readFloat((forceNode->value()).c_str()), type));
    addSensorMeasurement(m);
}

std::string Force1DSensor::getType() {
    return TYPE;
}

std::string Force1DSensor::getVersion() {
    return VERSION;
}

int Force1DSensor::getPriority() {
    return 60;
}
